
use rspc::{Type};
use serde::{Serialize};

use crate::meeting::{self, CreateMeetingData, MeetingParams, DeleteMeeting};

use super::{utils::LibraryRequest, RouterBuilder};

pub(crate) fn mount() -> RouterBuilder {
    return RouterBuilder::new()
        .query("version", |t| {
            #[derive(Serialize, Type)]
			pub struct BuildInfo {
				version: &'static str,
			}

			t(|_, _: ()| BuildInfo {
				version: "0.0.1",
			})
        })
        .library_query("get", |t| {
            t(|_, args: MeetingParams, library| async move {
                let results = meeting::MeetingManager::get(library.db, args).await?;
                Ok(results)
			})
        })
        .library_mutation("save", |t| {
            t(|_, args: CreateMeetingData, library| async move {
                Ok(meeting::MeetingManager::save(library.db, args).await?)
            })
        })
        .library_mutation("delete", |t| {
            t(|_, args: DeleteMeeting, library| async move {
                Ok(meeting::MeetingManager::delete(library.db, args).await?)
            })
        });
}
